﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using PGI.EN.OpcSistema;

namespace PGI.AD.OpcSistema
{
    public class OpcSistemaAd
    {
        public static List<OpcSistemaEn> OpcSistema_ListarOpcionesNoHabilitadas(int TipoUsuarioID)
        {
            SqlCommand command = null;
            SqlConnection connection = null;
            SqlDataReader reader = null;

            string sql = "MntOpcSistemaSOpcionesNoHabilitadas";

            try
            {
                connection = DataBaseFactory.SqlOpenDatabase("PGI");

                command = new SqlCommand(sql, connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@TipoUsuarioID", TipoUsuarioID);

                reader = command.ExecuteReader();
                List<OpcSistemaEn> lista = new List<OpcSistemaEn>();

                while (reader.Read())
                {
                    OpcSistemaEn opc_sistemaEn = new OpcSistemaEn();
                    opc_sistemaEn.OpcSistemaID = Convert.ToInt32(reader.GetValue(0));
                    opc_sistemaEn.Descripcion = Convert.ToString(reader.GetValue(1));
                    opc_sistemaEn.NombreControl = Convert.ToString(reader.GetValue(2));


                    lista.Add(opc_sistemaEn);
                }

                return lista;
            }

            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (reader != null)
                    reader.Close();
                DataBaseFactory.SqlCloseDatabase("PGI");
            }
        }
        public static List<OpcSistemaEn> OpcSistema_ListarOpcionesHabilitadas(int TipoUsuarioID)
        {
            SqlCommand command = null;
            SqlConnection connection = null;
            SqlDataReader reader = null;

            string sql = "MntOpcSistemaSOpcionesHabilitadas";

            try
            {
                connection = DataBaseFactory.SqlOpenDatabase("PGI");

                command = new SqlCommand(sql, connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@TipoUsuarioID", TipoUsuarioID);

                reader = command.ExecuteReader();
                List<OpcSistemaEn> lista = new List<OpcSistemaEn>();

                while (reader.Read())
                {
                    OpcSistemaEn opc_sistemaEn = new OpcSistemaEn();
                    opc_sistemaEn.OpcSistemaID = Convert.ToInt32(reader.GetValue(0));
                    opc_sistemaEn.Descripcion = Convert.ToString(reader.GetValue(1));
                    opc_sistemaEn.NombreControl = Convert.ToString(reader.GetValue(2));


                    lista.Add(opc_sistemaEn);
                }

                return lista;
            }

            catch (SqlException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            finally
            {
                if (reader != null)
                    reader.Close();
                DataBaseFactory.SqlCloseDatabase("PGI");
            }
        }
    }
}
